/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbftestpop', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AddRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model AddResponseBody = {
  sum?: int32(name='sum'),
}

model AddResponse = {
  headers: map[string]string(name='headers'),
  body: AddResponseBody(name='body'),
}

async function add(request: AddRequest): AddResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return addWithOptions(request, headers, runtime);
}

async function addWithOptions(request: AddRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AddResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.x)) {
    query.x = request.x;
  }
  if (!Util.isUnset(request.y)) {
    query.y = request.y;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('Add', '2021-09-16_10-36-00-223', 'HTTPS', 'GET', 'AK', `/kxRoaProduct/9_0_9/add`, 'json', req, runtime);
}

model ResolveOpenApiRequest {
  name?: string(name='name'),
  age?: int32(name='age'),
  teacher?: {
    teacherAge?: int32(name='teacherAge'),
    teacherName?: string(name='teacherName'),
  }(name='teacher'),
  friends?: [  map[string]any ](name='friends'),
}

model ResolveOpenApiResponseBody = {
  success?: boolean(name='success'),
  errorCode?: string(name='errorCode'),
  errorMsg?: string(name='errorMsg'),
}

model ResolveOpenApiResponse = {
  headers: map[string]string(name='headers'),
  body: ResolveOpenApiResponseBody(name='body'),
}

async function resolveOpenApi(request: ResolveOpenApiRequest): ResolveOpenApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return resolveOpenApiWithOptions(request, headers, runtime);
}

async function resolveOpenApiWithOptions(request: ResolveOpenApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ResolveOpenApiResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.name)) {
    query.name = request.name;
  }
  if (!Util.isUnset(request.age)) {
    query.age = request.age;
  }
  if (!Util.isUnset(request.teacher)) {
    query.teacher = request.teacher;
  }
  if (!Util.isUnset(request.friends)) {
    query.friends = request.friends;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('ResolveOpenApi', '2021-09-16_10-36-00-223', 'HTTPS', 'POST', 'AK', `/kxRoaProduct/9_0_9/resolveOpenApi`, 'json', req, runtime);
}

model AssetPublishTestOpenApiRequest {
  name?: string(name='name'),
  teacher?: {
    name?: string(name='name'),
    age?: int32(name='age'),
  }(name='teacher'),
}

model AssetPublishTestOpenApiResponseBody = {
  teacher?: {
    name?: string(name='name'),
    age?: string(name='age'),
  }(name='teacher'),
  success?: boolean(name='success'),
  errorCode?: string(name='errorCode'),
  errorMsg?: string(name='errorMsg'),
}

model AssetPublishTestOpenApiResponse = {
  headers: map[string]string(name='headers'),
  body: AssetPublishTestOpenApiResponseBody(name='body'),
}

async function assetPublishTestOpenApi(request: AssetPublishTestOpenApiRequest): AssetPublishTestOpenApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return assetPublishTestOpenApiWithOptions(request, headers, runtime);
}

async function assetPublishTestOpenApiWithOptions(request: AssetPublishTestOpenApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AssetPublishTestOpenApiResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.name)) {
    query.name = request.name;
  }
  if (!Util.isUnset(request.teacher)) {
    query.teacher = request.teacher;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('AssetPublishTestOpenApi', '2021-09-16_10-36-00-223', 'HTTPS', 'POST', 'AK', `/kxRoaProduct/9_0_9/assetPublishTestOpenApi`, 'json', req, runtime);
}

model AddTestRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model AddTestResponseBody = {
  sum?: int32(name='sum'),
}

model AddTestResponse = {
  headers: map[string]string(name='headers'),
  body: AddTestResponseBody(name='body'),
}

async function addTest(request: AddTestRequest): AddTestResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return addTestWithOptions(request, headers, runtime);
}

async function addTestWithOptions(request: AddTestRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AddTestResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.x)) {
    query.x = request.x;
  }
  if (!Util.isUnset(request.y)) {
    query.y = request.y;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('AddTest', '2021-09-16_10-36-00-223', 'HTTPS', 'POST', 'AK', `/kxRoaProduct/9_0_9/addTest`, 'json', req, runtime);
}

